//
//  ViewController.m
//  JsPatchDemo
//
//  Created by 尤春芬 on 17/1/17.
//  Copyright © 2017年 Yuna. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>{
    
    UITableView *myTable;
    
    NSArray *listArray;
    
     NSArray *dicArray;
}

@property (nonatomic) NSArray *data;

@end

@implementation ViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    [self createTable];
    
}

- (void)createTable{
    
    listArray = [NSArray arrayWithObjects:@"添加按钮未实现的方法",@"覆盖didSelectRowAtIndexPath方法", nil];

    dicArray = [[NSArray alloc] init];
    myTable = [[UITableView alloc] initWithFrame:self.view.frame];
    myTable.delegate = self;
    myTable.dataSource = self;
    myTable.rowHeight = 44;
    [self.view addSubview:myTable];
    
    UIView *bgView = [[UIView alloc] init];
    
 
}

- (void)reFreah{
    NSLog(@"_data-->%@",_data);
    
//     NSLog(@"listArray-->%@",listArray);
    
     NSLog(@"dicArray-->%@",dicArray);
       [myTable reloadData];
}

#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NSLog(@"%ld",indexPath.row);
}

#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return _data.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString *demoTableViewCell = @"TableViewCell";
    UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:demoTableViewCell];
    if(cell==nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:demoTableViewCell];
    }
    
    if (indexPath.row == 0) {
        
        UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(220, 2, 80, 40)];
        btn.backgroundColor = [UIColor redColor];
        [btn setTitle:@"按钮事件无" forState:UIControlStateNormal];
        btn.titleLabel.font = [UIFont systemFontOfSize:13];
        [btn addTarget:self action:@selector(onClick) forControlEvents:UIControlEventTouchUpInside];
        [cell.contentView addSubview:btn];

    }
    cell.textLabel.text = _data[indexPath.row];
    
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
